package c.b.a.c.a.a;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import c.b.a.c.a.c.a;
import c.b.a.c.a.c.j0;
import c.b.a.c.a.c.k;
import c.b.a.c.a.c.o;
import c.b.a.c.a.g.e;
import c.b.a.c.a.g.g;
import c.b.a.c.a.g.p;
import com.google.android.play.core.assetpacks.c0;

final class j {
    /* access modifiers changed from: private */
    public static final a e = new a("AppUpdateService");
    private static final Intent f = new Intent("com.google.android.play.core.install.BIND_UPDATE_SERVICE").setPackage("com.android.vending");

    /* renamed from: a  reason: collision with root package name */
    k<j0> f1941a;
    /* access modifiers changed from: private */

    /* renamed from: b  reason: collision with root package name */
    public final String f1942b;

    /* renamed from: c  reason: collision with root package name */
    private final Context f1943c;

    /* renamed from: d  reason: collision with root package name */
    private final c0 f1944d;

    public j(Context context) {
        this.f1942b = context.getPackageName();
        this.f1943c = context;
        if (o.a(context)) {
            this.f1941a = new k(c.b.a.c.a.f.a.a(context), e, "AppUpdateService", f, f.f1934a);
        }
        this.f1944d = new c0(context);
    }

    static /* synthetic */ Bundle b(j jVar, String str) {
        Integer num;
        Bundle bundle = new Bundle();
        bundle.putAll(h());
        bundle.putString("package.name", str);
        try {
            num = Integer.valueOf(jVar.f1943c.getPackageManager().getPackageInfo(jVar.f1943c.getPackageName(), 0).versionCode);
        } catch (PackageManager.NameNotFoundException unused) {
            e.e("The current version of the app could not be retrieved", new Object[0]);
            num = null;
        }
        if (num != null) {
            bundle.putInt("app.version.code", num.intValue());
        }
        return bundle;
    }

    static /* synthetic */ a c(j jVar, Bundle bundle, String str) {
        Bundle bundle2 = bundle;
        return a.b(str, bundle2.getInt("version.code", -1), bundle2.getInt("update.availability"), bundle2.getInt("install.status", 0), bundle2.getInt("client.version.staleness", -1) != -1 ? Integer.valueOf(bundle2.getInt("client.version.staleness")) : null, bundle2.getInt("in.app.update.priority", 0), bundle2.getLong("bytes.downloaded"), bundle2.getLong("total.bytes.to.download"), bundle2.getLong("additional.size.required"), jVar.f1944d.a(), (PendingIntent) bundle2.getParcelable("blocking.intent"), (PendingIntent) bundle2.getParcelable("nonblocking.intent"), (PendingIntent) bundle2.getParcelable("blocking.destructive.intent"), (PendingIntent) bundle2.getParcelable("nonblocking.destructive.intent"));
    }

    private static <T> e<T> g() {
        e.e("onError(%d)", -9);
        return g.a(new c.b.a.c.a.b.a(-9));
    }

    private static Bundle h() {
        Bundle bundle = new Bundle();
        bundle.putInt("playcore.version.code", 10702);
        return bundle;
    }

    public final e<a> e(String str) {
        if (this.f1941a == null) {
            return g();
        }
        e.f("requestUpdateInfo(%s)", str);
        p pVar = new p();
        this.f1941a.c(new g(this, pVar, str, pVar));
        return pVar.a();
    }
}
